home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 400_01 / socketpp-1.5 / pipestream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-30  |  1.4 KB  |  51 lines

  1. // pipestream.h -*- C++ -*- socket library
  2. // Copyright (C) 1992,1993 Gnanasekaran Swaminathan <gs4t@virginia.edu>
  3. // 
  4. // Permission is granted to use at your own risk and distribute this software
  5. // in source and binary forms provided the above copyright
  6. // notice and this paragraph are preserved on all copies.
  7. // This software is provided "as is" with no express or implied warranty.
  8. //
  9. // Version: 31Jan93 1.3
  10.  
  11. #ifndef _PIPESTREAM_H
  12. #define    _PIPESTREAM_H
  13.  
  14. #include <sockstream.h>
  15.  
  16. class ipipestream: public isockstream {
  17. public:
  18.     ipipestream (const char* cmd, ostream* tied=0);
  19. };
  20.  
  21. class opipestream: public osockstream {
  22. public:
  23.     opipestream (const char* cmd, ostream* tied=0);
  24. };
  25.  
  26. class iopipestream: public iosockstream {
  27. private:
  28.     iopipestream(const iopipestream& sp) {} 
  29.     iopipestream&    operator = (iopipestream&) { return *this; }
  30.     
  31. protected:
  32.     int        sp[2]; // socket pair
  33.     // childs pid if this is parent and
  34.     // 0 if this is child if object is created through
  35.     // iopipstream (sockbuf::type, int).
  36.     // -1 otherwise;
  37.     int        cpid;
  38.     iopipestream* next;  // next in the chain
  39.     
  40.     static iopipestream* head; // list to take care of by fork()
  41.     
  42. public:
  43.     iopipestream(sockbuf::type ty=sockbuf::sock_stream, int proto=0);
  44.     iopipestream(const char* cmd, ostream* tied=0);
  45.     
  46.     int    pid () const { return cpid; } // returns cpid
  47.     static int fork();     // sets cpid of all iopipestream* in the head
  48. };
  49.  
  50. #endif    _PIPESTREAM_H
  51.